{include file="common/head_s"/} 
<style type="text/css"> 
body,html{ background: #fff }
.layui-form-select dl{ max-height: 158px!important }
</style> 
<div class="pd15">
<form class="layui-form layui-form-pane">
    <div class="layui-form-item">
        <label class="layui-form-label">所属商城</label>
        <div class="layui-input-block">
            <select name="shopid" id="shopid" ng-model="field.shopid" lay-filter="shopid" lay-verify="required">
                <option value="">请选择所属商城</option>
                {volist name="shoplist" id="vo"}<option value="{$vo.id}" id="{$vo.name}">{$vo.name}</option>  {/volist}
            </select> 
        </div>
        <input type="hidden" name="shopname" id="shopname" lay-verify="required" class="layui-input">
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择币种</label>
        <div class="layui-input-block">
            <select name="cionid" id="cionid" ng-model="field.cionid" lay-filter="cionid" lay-verify="required">
                <option value="">请选择币种</option>
                {volist name="cionlist" id="vo"}<option value="{$vo.id}">{$vo.name}/{$vo.name_en}</option>{/volist}
            </select>
        </div>
        <input type="hidden" name="cionname" id="cionname" lay-verify="required" class="layui-input">
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">通道名称</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" placeholder="请输入通道名或广告语" class="layui-input">
        </div>
    </div> 
    <div class="layui-form-item">
        <label class="layui-form-label">手续费率</label>
        <div class="layui-input-block">
            <input type="text" name="rate" lay-verify="required" value="{$userlv}" placeholder="手续费率%" class="layui-input">
        </div>
    </div> 
    <div class="layui-form-item" style="margin-bottom: 0px!important; text-align: center;">
        <div class="layui-btn layui-btn-primary" id="overbtn">暂不开通</div>
        <button type="submit" class="layui-btn" lay-filter="addbtn" lay-submit><i class="layui-icon">&#x1005;</i>立即开通</button>
    </div>
</form> 
</div>
<script src="/static/plugins/layui/layui.js"></script> 
<script>
layui.use(['jquery','form'], function(){
    var $ = layui.jquery ,form = layui.form;   
    form.on('select(shopid)', function(data){
        var name=$("#shopid option:checked").text(); 
        $('#shopname').val(name);  
        var shopid = data.value;
        $.get("{:url('channel/getCion')}?shopid=" + shopid, function (data) {
            var html = '<option value="">请选择币种</option>';
            $.each(data, function (i, value) {
                html += '<option value="' + value.id + '">' + value.name + '/'+value.name_en+'</option>';
            });
            $('#cionid').html(html); 
            form.render()
        });
    });  
    form.on('select(cionid)', function(data){
        var name=$("#cionid option:checked").text(); 
        $('#cionname').val(name);  
    });  
    // 提交监听
    form.on('submit(addbtn)', function (data) {   
        data.field.userid="{$thisuserid}";
        $.post("{:url('user/channel/addchannel')}",data.field,function(res){ 
            if(res.code===1){
                layer.msg(res.msg,{time:2000,icon:1},function(){  
                    parent.location.reload();
                });
            }else{
                layer.msg(res.msg,{time:1000,icon:2}); 
            }
        });
        return false;
    });
    $('#overbtn').on('click', function() {
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭，强制关闭弹窗
    }); 
}); 
</script> 
</body>
</html>